package com.demo.dubbo.springboot;

import java.io.IOException;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import com.reger.dubbo.rpc.filter.ConsumerFilter;
import com.reger.dubbo.rpc.filter.ProviderFilter;

@SpringBootApplication
public class App {

	public static void main(String[] args) throws IOException {
		SpringApplication.run(App.class, args);
		//为了防止服务端退出，按任意键或者 ctrl-c 退出。
        System.in.read();
	}

	@Bean
	public ConsumerFilter consumerFilter1() {
	    return (joinPoint) -> {
	        System.out.println("调用接口{" + joinPoint.getInterface() + "} ------》》（先打印）");
	        return joinPoint.proceed();  // 该方法用于调用实际业务逻辑
	    };
	}

	@Bean
	public ProviderFilter providerFilter() {
	    return (joinPoint) -> {
	    	System.out.println("接口{" + joinPoint.getInterface() + "}被调用 ");
	        return joinPoint.proceed(); // 该方法用于调用实际业务逻辑
	    };
	}

}
